/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:ProjectInfoActivity.java
 *  项目功能:
 */

package com.jg.myproject.module.projectinfo;

import android.widget.TextView;

import com.allen.library.SuperTextView;
import com.jg.myproject.api.Const;
import com.jg.myproject.api.bean.BaseEntity;
import com.jg.myproject.api.bean.CommonRequestBean;
import com.jg.myproject.api.bean.reponse.CommonReponseBean;
import com.jg.myproject.module.base.BaseActivity;
import com.jg.myproject.presenter.ProjectInfoPresenter;
import com.jg.myproject.pview.IProjectInfoView;
import com.jg.myproject.utils.RxSPTool;
import com.zcr.myproject.R;


import butterknife.BindView;

/**
 * Created by llz on 2018/11/16.
 */
public class ProjectInfoActivity  extends BaseActivity implements IProjectInfoView{
    @BindView(R.id.tv_title)
    TextView mTvTitle;
    @BindView(R.id.other)
    TextView mOther;
    @BindView(R.id.tv_back)
    TextView mTvBack;
    @BindView(R.id.stv_01)
    SuperTextView mStv01;
    @BindView(R.id.stv_02)
    SuperTextView mStv02;
    @BindView(R.id.stv_03)
    SuperTextView mStv03;
    @BindView(R.id.stv_04)
    SuperTextView mStv04;
    @BindView(R.id.stv_05)
    SuperTextView mStv05;
    @BindView(R.id.stv_06)
    SuperTextView mStv06;
    @BindView(R.id.stv_07)
    SuperTextView mStv07;
    @BindView(R.id.stv_08)
    SuperTextView mStv08;
    @BindView(R.id.stv_09)
    SuperTextView mStv09;
    @BindView(R.id.stv_10)
    SuperTextView mStv10;
    @BindView(R.id.stv_11)
    SuperTextView mStv11;
    @BindView(R.id.stv_12)
    SuperTextView mStv12;
    @BindView(R.id.stv_13)
    SuperTextView mStv13;
    @BindView(R.id.stv_14)
    SuperTextView mStv14;
    @BindView(R.id.stv_15)
    SuperTextView mStv15;
    @BindView(R.id.stv_16)
    SuperTextView mStv16;

     ProjectInfoPresenter mProjectInfoPresenter;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_project_info; //1.加载布局
    }
    @Override
    protected void initViews() {
        initTitle(true, "工程信息");//2.初始化工作
        mProjectInfoPresenter = new ProjectInfoPresenter(this);
    }
    @Override
    protected void updateViews(boolean isRefresh) {
        CommonRequestBean commonRequestBean = new CommonRequestBean();
        String id = RxSPTool.getString(this,Const.PROJECTID);
        commonRequestBean.setProjectId(id);
        mProjectInfoPresenter.getData(commonRequestBean);  // 3.访问网络获取数据
    }
    @Override
    public void getReponseBeans(BaseEntity<CommonReponseBean> bean) {//4.处理服务器返回的数据
        CommonReponseBean commonReponseBean1 = bean.getBeans().get(0);
        mStv01.setCenterString(commonReponseBean1.getProjectCode());
        mStv02.setCenterString(commonReponseBean1.getProjectName());
        mStv03.setCenterString(commonReponseBean1.getMonitorCode());
        mStv04.setCenterString(commonReponseBean1.getProjectAddress());
        mStv05.setCenterString(commonReponseBean1.getGzmHeight());
        mStv06.setCenterString(commonReponseBean1.getGzmArea());
        mStv07.setCenterString(commonReponseBean1.getProjectType());
        mStv08.setCenterString(commonReponseBean1.getMonitorOrg());
        String jdks = "";
        String jdy = "";
        for(CommonReponseBean commonReponseBean:commonReponseBean1.getJdList()){
            jdks+=commonReponseBean.getDeptName()+" ";
            jdy+=commonReponseBean.getPersonName()+"/"+commonReponseBean.getTel()+" ";
        }
        mStv09.setCenterString(jdks);
        mStv10.setCenterString(jdy);
        mStv11.setCenterString(commonReponseBean1.getBuildOrg());
        String jsdw = "";
        for(CommonReponseBean commonReponseBean:commonReponseBean1.getJsList()){
            jsdw+=commonReponseBean.getPersonName()+"/"+commonReponseBean.getTel()+" ";
        }
        mStv12.setCenterString(jsdw);
        mStv13.setCenterString(commonReponseBean1.getConstructOrg());
        String sgdw = "";
        for(CommonReponseBean commonReponseBean:commonReponseBean1.getSgList()){
            sgdw+=commonReponseBean.getPersonName()+"/"+commonReponseBean.getTel()+" ";
        }
        mStv14.setCenterString(sgdw);

        mStv15.setCenterString(commonReponseBean1.getConstructOrg());
        String jldw = "";
        for(CommonReponseBean commonReponseBean:commonReponseBean1.getJlList()){
            jldw+=commonReponseBean.getPersonName()+"/"+commonReponseBean.getTel()+" ";
        }
        mStv16.setCenterString(jldw);

    }
}
